<!DOCTYPE html>
<html class="no-js" lang="zxx">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="x-ua-compatible" content="ie=edge" />
  <title>Post Job - JobGrids Job Portal HTML Template.</title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="shortcut icon" type="image/x-icon" href="assets/images/favicon.svg" />
  <!-- Place favicon.ico in the root directory -->

  <!-- Web Font -->
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
        rel="stylesheet">

  <!-- ========================= CSS here ========================= -->
  <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
  <link rel="stylesheet" href="assets/css/LineIcons.2.0.css" />
  <link rel="stylesheet" href="assets/css/animate.css" />
  <link rel="stylesheet" href="assets/css/tiny-slider.css" />
  <link rel="stylesheet" href="assets/css/glightbox.min.css" />
  <link rel="stylesheet" href="assets/css/main.css" />

</head>

<body>
<!--[if lte IE 9]>
<p class="browserupgrade">
  You are using an <strong>outdated</strong> browser. Please
  <a href="https://browsehappy.com/">upgrade your browser</a> to improve
  your experience and security.
</p>
<![endif]-->

<div id="loading-area"></div>

<!-- Start Header Area -->
<header class="header">
  <div class="navbar-area">
    <div class="container">

      <div class="row align-items-center">

        <div class="col-lg-12">
          <nav class="navbar navbar-expand-lg">
            <a class="navbar-brand logo" href="index-hr.html">
              <img class="logo1" src="assets/images/logo/logo.svg" alt="Logo" />
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse"
                    data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
                    aria-expanded="false" aria-label="Toggle navigation">
              <span class="toggler-icon"></span>
              <span class="toggler-icon"></span>
              <span class="toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse sub-menu-bar" id="navbarSupportedContent">
              <ul id="nav" class="navbar-nav ml-auto">
                <li class="nav-item">
                  <a  href="index-hr.html">主页</a>
                </li>



                    <li class="nav-item">
                      <a  href="browse-jobs.html">职位搜索</a>
                    </li>

                <li class="nav-item"><a href="#">职位管理 </a>
                  <ul class="sub-menu">
                    <li><a href="post-job.html">发布职位</a></li>
                    <li><a href="manage-jobs.html">职位查看与编辑</a></li>
                    <li><a  href="have-manage-resumes.html">已处理申请</a></li>
                    <li><a  href="manage-resumes.html">待处理申请</a></li>

                  </ul>
                </li>



                <li class="nav-item">
                  <a href="blog-grid-sidebar.html">论坛</a></li>
                </li>

                <li class="nav-item"><a href="contact.html">联系我们 </a> </li>


                <li class="nav-item"><a href="#">其他</a>
                  <ul class="sub-menu">
                    <!-- <li><a href="index.html" onclick="logout()">Log Out</a></li> -->
                    <li><a onclick="checkloginuser()">Personal Info</a></li>
                    <li><a href="about-us.html" onclick="addtoken()">About Us</a></li>
                    <li><a href="job-list.html">Job List</a></li>
                    <li><a href="job-details.html">Job Details</a></li>
                    <li><a href="resume.html">Resume Page</a></li>
                    <li><a href="privacy-policy.html">Privacy Policy</a></li>
                    <li><a href="faq.html">Faq</a></li>
                    <li><a href="pricing.html">Our Pricing</a></li>
                    <li><a href="404.html">404 Error</a></li>
                    <li><a href="mail-success.html">Mail Success</a></li>
                  </ul>
                </li>

                <li class="nav-item">
                  <a href="#" class="active">个人中心</a>
                  <ul class="sub-menu">
                    <li><a class="active" href="showhrinfo.html">信息编辑</a></li>
                    <li><a href="job-alerts.html">申请进度</a></li>
                    <li><a href="job-alerts.html">消息提醒</a></li>
                  </ul>
                </li>
                <li class="nav-item login">

                  <a href="showhrinfo.html" id="shownameid" >
                  </a>
                  <ul class="sub-menu">
                    <li><a href="index.html" onclick="logout()">退出登录</a></li>
                  </ul>
                </li>
              </ul>
            </div>
            <!-- navbar collapse -->
            <!--登录显示用户名的地方，点击进入到个人中心界面-->



          </nav>
          <!-- navbar -->
        </div>
      </div>
      <!-- row -->
    </div>
    <!-- container -->
  </div>
  <!-- navbar area -->
</header>
<!-- End Header Area -->



<section class="job-change section">
  <div class="container">
    <div class="row">
      <div class="col-lg-10 offset-lg-1 col-12">
        <div class="job-information">
          <h3 class="title">更改职位信息</h3>

          <form  id="changejobform" method="post" onsubmit="return false" >

            <input style="display:none" name="jobid" id="jobdetailid" >

            <div class="row">
              <div class="col-lg-12">
                <div class="form-group">
                  <label>职位名称*</label>
                  <input id="jobdetailname" class="form-control" type="text" name="title">
                </div>
              </div>

<!--              <div class="col-lg-6 col-md-6">-->
<!--                <div class="form-group">-->
<!--                  <label>职位数目</label>-->
<!--                  <input id="jobdetailnum" class="form-control" type="text" name="jobid">-->
<!--                </div>-->
<!--              </div>-->

              <div class="col-lg-6 col-md-6">
                <div class="form-group">
                  <label>HR账号</label>
                  <input id="jobdetailhrid" class="form-control" type="text" name="hrid">
                </div>
              </div>

              <div class="col-lg-6 col-md-6">
                <div class="form-group">
                  <label>发布状态</label>
                  <input id="jobdetailpoststat" class="form-control" type="text" name="poststat">
                </div>
              </div>

              <div class="col-lg-6 col-md-6">
                <div class="form-group">
                  <label>招聘状态</label>
                  <input id="jobdetailrecruistat" class="form-control" type="text" name="recruitstat">
                </div>
              </div>



              <div class="col-lg-6 col-md-6">
                <div class="form-group">
                  <label>职业类型</label>
                  <select class="select" id="jobdetailkindid" name="jobkind">
                    <option value="1">全职</option>
                    <option value="2">Part Time</option>
                    <option value="3">Contract</option>
                    <option value="4">Internship</option>
                    <option value="5">Office</option>
                  </select>
                </div>
              </div>


              <div class="col-lg-6 col-md-6">
                <div class="form-group">
                  <label>更新时间 </label>
                  <input id="jobdetailtime" class="form-control" type="text" name="updatetime">
                </div>
              </div>

              <div class="col-lg-6 col-md-6">
                <div class="form-group">
                  <label>薪资范围</label>
                  <select class="select" id="jobdetailsalrayid" name="salary">
                    <option value="1">Default</option>
                    <option value="2">20000 To 30000</option>
                    <option value="3">40000 To 50000</option>
                    <option value="4">60000 To 70000</option>
                    <option value="5">80000 To 90000</option>
                  </select>
                </div>
              </div>

              <div class="col-lg-12">
                <div class="form-group">
                  <label>Job Location</label>
                  <input id="jobdetailloc" class="form-control" type="text" name="loc">
                </div>
              </div>

              <div class="col-lg-12">
                <div class="form-group">
                  <label>Job Education Required</label>
                  <input id="jobdetaileduc" class="form-control" type="text" name="educ">
                </div>
              </div>

              <div class="col-lg-12">
                <div class="form-group">
                  <label>Job Description</label>
                  <textarea id="jobdetaildesc" name="jobdesc" class="form-control" rows="5"></textarea>
                </div>
              </div>


              <div class="col-lg-12">
                <div class="form-group">
                  <label>Needed work experience</label>
                  <textarea id="jobdetailneedexpr" name="exprdesc" class="form-control" rows="5"></textarea>
                </div>
              </div>

            </div>


            <div class="row">

              <div class="col-lg-12 button">

                <button class="btn " id="jobmodifybtn" onclick="jobmodify()" >修改岗位信息
                </button>
                <button class="btn " id="jobsavebtn" onclick="jobsave()" >保存岗位信息
                </button>
              </div>
            </div>
          </form>

        </div>
      </div>
    </div>
  </div>
</section>





<!-- Start Footer Area -->
<footer class="footer">
  <div class="footer-bottom">
    <div class="container">
      <div class="inner">
        <div class="row">
          <div class="col-lg-6 col-md-6 col-12">
            <div class="left">
              <p><a target="_blank" >软件工程大作业</a></p>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-12">
            <div class="right">
              <ul>
                <li><a href="privacy-policy.html">用户手册</a></li>
                <li><a href="#">项目文档</a></li>
                <li><a href="https://gitee.com/Yuan-Wi/software-engineering-team/tree/master/">gitee</a></li>
                <li><a href="contact.html">联系我们</a></li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- End Footer Middle -->
</footer>
<!--/ End Footer Area -->

<!-- ========================= scroll-top ========================= -->
<a href="#" class="scroll-top btn-hover">
  <i class="lni lni-chevron-up"></i>
</a>

<!-- ========================= JS here ========================= -->

<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

<script src="assets/js/wow.min.js"></script>
<script src="assets/js/tiny-slider.js"></script>
<script src="assets/js/glightbox.min.js"></script>
<script src="assets/js/main.js"></script>
<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript">
  //获取url中的jobId参数值，查询接口/system/job/{jobId} 获取数据并渲染到页面
  alert(window.location.search)
  function getParam(name, defaultValue){
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
      var pair = vars[i].split("=");
      if(pair[0] == name){return pair[1] + (pair[2] ? '=' + pair[2] : '');}
    }
    return(defaultValue == undefined ? null : defaultValue);
  };

  var jobId = getParam('jobId',0);
  // jobId = parseInt(jobId, 10); // 将jobId转换为整数
  // // 如果jobId不是一个有效的数字，显示错误信息
  // if (isNaN(jobId) || jobId <= 0) {
  //   alert("Invalid jobId");
  //   // 阻止进一步执行
  //   throw new Error("Invalid jobId");
  // }

  //===========最初需要完成hr的内容的加载
  $(document).ready(function(){
    $.ajax({
      url: "http://localhost:8080/system/job/jobdetail/"+jobId,
      data: jobId,
      type: "GET",
      success: function(result){
        if(result.code==200) {
          // 获取所有的keys
          const keys = Object.keys(result);

          // 循环获取对应的value并显示
          keys.forEach(key => {

              //temkeys=hr,company
              const temkeys = Object.keys(result[key]);
              temkeys.forEach(temkey => {
                if(temkey=="job"){
                  const job = result["data"]["job"];
                   alert(job.jobName);
                  document.getElementById("jobdetailid").value=job.jobId;

                  document.getElementById("jobdetailname").value=job.jobName;
                 // document.getElementById("jobdetailnum").value=job.hrTel;
                  document.getElementById("jobdetailhrid").value=job.hrId;
                  document.getElementById("jobdetailpoststat").value=job.jobPoststat;
                  document.getElementById("jobdetailrecruistat").value=job.jobRecruitstat;
                  document.getElementById("jobdetailkindid").value=job.jobKind;
                  document.getElementById("jobdetailtime").value=job.jobInfoupdatetime;
                  document.getElementById("jobdetailsalrayid").value=job.jobSalrange;
                  document.getElementById("jobdetailloc").value=job.jobWorkaddr;
                  document.getElementById("jobdetaildesc").value=job.jobDesc;
                  document.getElementById("jobdetailneedexpr").value=job.jobWorkexp;
                  document.getElementById("jobdetaileduc").value=job.jobEdureq;

                }

              });

          });
          //var hrform = document.getElementById("hrupdateform");
          //var companyform = document.getElementById("companyupdateform");
          //遍历表单设置元素readonly
          $('input').attr('readonly', true);

          $("#jobdetailsalrayid").prop('disabled', false);
          $("#jobdetailkindid").prop('disabled', false);
          $("#jobsavebtn").attr("disabled", true);
          //$("#companysavebtn").attr("disabled", true);


        }
        else {
          alert(result.code+result.msg);
        }
      },
      error: function(){
        alert("请刷新重试_changejobdetail");
      },
    });
  });



  function jobmodify(){
    //设置save可用，表格元素可修改
    alert("modify");
    $("#jobsavebtn").attr("disabled", false);
    $('#changejobform input[readonly]').removeAttr('readonly');
  };
  function jobsave(){
    //设置save不可用，表格元素提交后台修改
    alert("save");
    $.ajax({
      url: "http://localhost:8080/system/job/updatejobdetail",
      type: "POST",
      dataType: "json",
      data: $('#changejobform').serialize(),
      success: function(result){
        if(result.code==200){
          alert("岗位信息修改成功");
          //遍历表单设置元素readonly,按钮不可修改
          $('#changejobform input').prop('readonly', true);
          $("#jobsavebtn").attr("disabled", true);
        }
        else{
          alert(result.code);
        }
      },
      error: function(){
        alert("修改岗位信息失败，稍后重试");
      },
    });
  };





  //===========最初需要完成名字的显示
  $(document).ready(function(){


    /*   alert("新方法");*/
    $.ajax({
      url: "http://localhost:8080/mylogingetusername",
      type: "GET",
      data: {token : window.localStorage.getItem("user")?window.localStorage.getItem("user"):"notoken"},
      success: function(result){
        // alert(result.code);
        if(result.code==200){
          alert(result.msg);
          document.getElementById('shownameid').textContent = "欢迎"+result.msg+"登录";
        }
        else {
          alert(result.code+result.msg);
        }
      },
      error: function(){
        alert("请刷新重试");
      },
    });
  });

  function checkloginuser(){
    //window.location.reload();

    $.ajax({
      url: "http://localhost:8080/mycheckloginuser",
      type: "GET",
      data: {token : window.localStorage.getItem("user")?window.localStorage.getItem("user"):"notoken"},
      success: function(result){
        // alert(result.code);
        if(result.code==200){
          if(result.msg=="hrlogin"){

            location.href="http://localhost/static/html/showhrinfo.html";
          }
          else if(result.msg=="employeelogin"){window.location.href="http://localhost/static/html/showseekerinfo.html";}
        }
        else {
          alert(result.code+result.msg);
        }
      },
      error: function(){
        alert("请刷新重试");
      },
    });

  };
  //其他业务请求从本地浏览器中存的token获取加入请求头

  function logout(){
    window.localStorage.removeItem('user');
    location.href="http://localhost/static/html/index.html";
  };

  var loginuserinfo;//当前登录用户的角色和id
  /*解析token*/
  function sparsetoken(){
    var token;
    $(function(){
      token = window.localStorage.getItem("user");//这可以得到当前登录用户的token
      alert("user="+token);
      alert(window.location.href);
      //data.data.normal_login_token为发送Ajax获取到的token信息
      var strings = token.split(".");//通过split()方法将token转为字符串数组
      //取strings[1]数组中的第二个字符进行解析
      var userinfo = JSON.parse(decodeURIComponent(escape(window.atob(strings[1].replace(/-/g, "+").replace(/_/g, "/")))));
      loginuserinfo = userinfo;//赋给全局变量
      //然后可以拿到解析后的数据，可以console.log()打印下，roleid是在表中的id，loginrole=hrlogin或seekerlogin
      alert(userinfo.roleid+userinfo.loginrole+'userinfo');

    });
    /*  $.ajax({
        url: "http://localhost:8080/myabout",
        type: "GET",
        xhrFields: {
                        withCredentials: true
                    },
        success: function(result){
          alert("成功");
        },
        error: function(){
        alert("失败");
        },
      });*/
  };


  //===========根据选择的角色先跳转到对应的控制器去insert(id,phone,pwd)
  function getsignuproleradioval(value){
    signrole=value;
    if(value=="hrsignup"){
      alert("选择HR身份注册");
      //显示全部必填信息
      document.getElementById("hrsignupposclass").classList.remove("hidden");
      document.getElementById("hrsignupcompanyclass").classList.remove("hidden");
      //设置为必填
      document.getElementById("hrsignuppos").setAttribute('required', true);
      document.getElementById("hrsignupcompany").setAttribute('required', true);
      //求职者的隐藏不必填
      document.getElementById("seekersignemailclass").classList.add("hidden");
      document.getElementById("seekerdateclass").classList.add("hidden");
      document.getElementById("seekeriseduclass").classList.add("hidden");
      document.getElementById("seekersigngenderclass").classList.add("hidden");
      document.getElementById("seekersigngender").removeAttribute('required');
      document.getElementById("seekersignemail").removeAttribute('required');
      document.getElementById("seekersigndate").removeAttribute('required');
      document.getElementById("seekerisedu").removeAttribute('required');

      //跳到对应的控制器中操作数据库
      // document.getElementById("signupform").action = "http://localhost:8080/hrsignup";
    }
    else if(value=="employeesignup"){
      alert("选择求职者身份注册");
      //Hr的隐藏不必填
      document.getElementById("hrsignupposclass").classList.add("hidden");
      document.getElementById("hrsignupcompanyclass").classList.add("hidden");
      document.getElementById("hrsignuppos").removeAttribute('required');
      document.getElementById("hrsignupcompany").removeAttribute('required');
      //显示求职者注册必填信息
      document.getElementById("seekersignemailclass").classList.remove("hidden");
      document.getElementById("seekerdateclass").classList.remove("hidden");
      document.getElementById("seekeriseduclass").classList.remove("hidden");
      document.getElementById("seekersigngenderclass").classList.remove("hidden");
      document.getElementById("seekersigngender").setAttribute('required', true);
      document.getElementById("seekersignemail").setAttribute('required', true);
      document.getElementById("seekersigndate").setAttribute('required', true);
      document.getElementById("seekerisedu").setAttribute('required', true);
      // document.getElementById("signupform").action = "http://localhost:8080/employeesignup";
    }
  };

  //===========确认两次密码一致
  function checkpwd() {
    var password = document.getElementById("inputpwd").value;
    var repassword = document.getElementById("confirmpwd").value;
    //判断输入框为空
    if(!password){
      document.getElementById("tishi").innerHTML="<br><font color='red'>请输入密码!</font>";
      document.getElementById("signupbtn").disabled = true;
    }
    else if(password == repassword) {
      document.getElementById("tishi").innerHTML="<br><font color='green'>两次密码输入一致</font>";
      document.getElementById("signupbtn").disabled = false;
    }
    else {
      document.getElementById("tishi").innerHTML="<br><font color='red'>两次输入密码不一致!</font>";
      document.getElementById("signupbtn").disabled = true;
    }
  };
</script>
</body>

</html>
